//
//  HomeVCModel.swift
//  Weibo项目
//
//  Created by vn on 16/7/23.
//  Copyright © 2016年 vn. All rights reserved.
//

import UIKit

class HomeVCModel: NSObject {
    
    // MARK: - 模型属性
    /// 创建时间
    var created_at: String?
    /// 微博ID
    var id: Int64 = 0
    /// 微博信息内容
    var text: String?
    /// 微博来源
    var source: String?
    
    //字典转模型,用户信息
    var user: UserModel?
    
    //  转发微博
    var retweeted_status:HomeVCModel?

    init(dict:[String: AnyObject]) {
        
        super.init()
        
        setValuesForKeysWithDictionary(dict)
      
        
        
    }
    
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user"{
           
          //判断key为不为nil,或者能不能转为字典,用户信息
            guard let v = value as? [String:AnyObject] else{
                
                return
                
            }
           
            user = UserModel(dict:v)
            
       
        //原创微博
        }else if key == "retweeted_status"{
            
            
            guard let v = value as? [String:AnyObject] else{
                
                
                return
            }
            
              retweeted_status = HomeVCModel(dict:v)
            
            //就是微博信息
        
        }else{
            
            
            //如果不是,让系统继续赋值
            super.setValue(value, forKey: key)
            
        }
        
      
    }
    
    
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
        
        
    }
    
    
    
    
    
    
    
}
